package com.wz.project.sap.POST_TMDATA_RETURNDATA.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.sap.POST_TMDATA_RETURNDATA.domain.YppRfcPostTmdataReturndata;
import com.wz.project.sap.POST_TMDATA_RETURNDATA.service.IYppRfcPostTmdataReturndataService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 生产订单入库RETURNDATAController
 * 
 * @author wz
 * @date 2022-09-21
 */
@Controller
@RequestMapping("/POST_TMDATA_RETURNDATA/POST_TMDATA_RETURNDATA")
public class YppRfcPostTmdataReturndataController extends BaseController
{
    private String prefix = "POST_TMDATA_RETURNDATA/POST_TMDATA_RETURNDATA";

    @Autowired
    private IYppRfcPostTmdataReturndataService yppRfcPostTmdataReturndataService;

    @RequiresPermissions("POST_TMDATA_RETURNDATA:POST_TMDATA_RETURNDATA:view")
    @GetMapping()
    public String POST_TMDATA_RETURNDATA()
    {
        return prefix + "/POST_TMDATA_RETURNDATA";
    }

    /**
     * 查询生产订单入库RETURNDATA列表
     */
//    @RequiresPermissions("POST_TMDATA_RETURNDATA:POST_TMDATA_RETURNDATA:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YppRfcPostTmdataReturndata yppRfcPostTmdataReturndata)
    {
        startPage();
        List<YppRfcPostTmdataReturndata> list = yppRfcPostTmdataReturndataService.selectYppRfcPostTmdataReturndataList(yppRfcPostTmdataReturndata);
        return getDataTable(list);
    }

    /**
     * 导出生产订单入库RETURNDATA列表
     */
//    @RequiresPermissions("POST_TMDATA_RETURNDATA:POST_TMDATA_RETURNDATA:export")
    @Log(title = "生产订单入库RETURNDATA", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YppRfcPostTmdataReturndata yppRfcPostTmdataReturndata)
    {
        List<YppRfcPostTmdataReturndata> list = yppRfcPostTmdataReturndataService.selectYppRfcPostTmdataReturndataList(yppRfcPostTmdataReturndata);
        ExcelUtil<YppRfcPostTmdataReturndata> util = new ExcelUtil<YppRfcPostTmdataReturndata>(YppRfcPostTmdataReturndata.class);
        return util.exportExcel(list, "POST_TMDATA_RETURNDATA");
    }

    /**
     * 新增生产订单入库RETURNDATA
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存生产订单入库RETURNDATA
     */
    @RequiresPermissions("POST_TMDATA_RETURNDATA:POST_TMDATA_RETURNDATA:add")
    @Log(title = "生产订单入库RETURNDATA", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YppRfcPostTmdataReturndata yppRfcPostTmdataReturndata)
    {
        return toAjax(yppRfcPostTmdataReturndataService.insertYppRfcPostTmdataReturndata(yppRfcPostTmdataReturndata));
    }

    /**
     * 修改生产订单入库RETURNDATA
     */
    @GetMapping("/edit/{AUFNR}")
    public String edit(@PathVariable("AUFNR") String AUFNR, ModelMap mmap)
    {
        YppRfcPostTmdataReturndata yppRfcPostTmdataReturndata = yppRfcPostTmdataReturndataService.selectYppRfcPostTmdataReturndataById(AUFNR);
        mmap.put("yppRfcPostTmdataReturndata", yppRfcPostTmdataReturndata);
        return prefix + "/edit";
    }

    /**
     * 修改保存生产订单入库RETURNDATA
     */
    @RequiresPermissions("POST_TMDATA_RETURNDATA:POST_TMDATA_RETURNDATA:edit")
    @Log(title = "生产订单入库RETURNDATA", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YppRfcPostTmdataReturndata yppRfcPostTmdataReturndata)
    {
        return toAjax(yppRfcPostTmdataReturndataService.updateYppRfcPostTmdataReturndata(yppRfcPostTmdataReturndata));
    }

    /**
     * 删除生产订单入库RETURNDATA
     */
    @RequiresPermissions("POST_TMDATA_RETURNDATA:POST_TMDATA_RETURNDATA:remove")
    @Log(title = "生产订单入库RETURNDATA", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yppRfcPostTmdataReturndataService.deleteYppRfcPostTmdataReturndataByIds(ids));
    }
}
